package container.set;

import java.util.HashSet;
import java.util.Set;
import java.util.UUID;

public class T01_HashSet {
    /**
     * java.util.ConcurrentModificationException
     */
    public static void main(String[] args) {
        Set<String> set = new HashSet<>(); // 底层为 new HashMap<>();

        for (int i = 0; i < 30; i++) {
            new Thread(() -> {
                /** @see HashSet#add(java.lang.Object) 只存 key */
                set.add(UUID.randomUUID().toString().substring(0, 8));
                System.out.println(set);
            }, String.valueOf(i)).start();
        }
    }
}
